//
//  HWHelpCell.m
//  嗨文
//
//  Created by 响当当 on 2019/1/18.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWHelpCell.h"

@interface HWHelpCell()
@property (nonatomic, strong)UIImageView *iconQImageView;//icon问图标
@property (nonatomic, strong)UIImageView *iconAImageView;//icon答图标
@property (nonatomic, strong)UILabel *qContextLabel;//问标题
@property (nonatomic, strong)UILabel *aContextLabel;//答标题
@end

@implementation HWHelpCell

- (UIImageView *)iconQImageView
{
    if (!_iconQImageView)
    {
        _iconQImageView = [[UIImageView alloc]initWithFrame:CGRectMake(12*kUIScaleBasePlus,16*kUIScaleBasePlus,20*kUIScaleBasePlus,20*kUIScaleBasePlus)];
        _iconQImageView.image = [UIImage imageNamed:@"help_question"];
    }
    return _iconQImageView;
}


- (UILabel *)qContextLabel
{
    if (!_qContextLabel)
    {
        _qContextLabel = [HWUtilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.iconQImageView.frame)+12*kUIScaleBasePlus,17*kUIScaleBasePlus,300*kUIScaleBasePlus,0)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x333333)
                                                textFont:16*kUIScaleBasePlus];
//        _qContextLabel.numberOfLines = 0;
    }
    return _qContextLabel;
}

- (UILabel *)aContextLabel
{
    if (!_aContextLabel)
    {
        _aContextLabel = [HWUtilties creatLabelWithFrame:CGRectMake(43*kUIScaleBasePlus,0,300*kUIScaleBasePlus,0)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x6E6E6E)
                                                textFont:16*kUIScaleBasePlus];
        _aContextLabel.numberOfLines = 0;
    }
    return _aContextLabel;
}


- (UIImageView *)iconAImageView
{
    if (!_iconAImageView)
    {
        _iconAImageView = [[UIImageView alloc]initWithFrame:CGRectMake(12*kUIScaleBasePlus,0,20*kUIScaleBasePlus,20*kUIScaleBasePlus)];
        _iconAImageView.image = [UIImage imageNamed:@"help_answer"];
    }
    return _iconAImageView;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.iconQImageView];
        [self.contentView addSubview:self.qContextLabel];
        [self.contentView addSubview:self.aContextLabel];
        [self.contentView addSubview:self.iconAImageView];
    }
    return self;
}

#pragma mark - 获取cell的高度
- (CGFloat)getBackRowHeight:(NSDictionary *)dic
{
    self.qContextLabel.text = dic[@"qContext"];
    [self.qContextLabel sizeToFit];
    
    self.aContextLabel.text = dic[@"aContext"];
    [self.aContextLabel sizeToFit];
    [self.aContextLabel setY:CGRectGetMaxY(self.qContextLabel.frame)+20*kUIScaleBasePlus];

    return CGRectGetMaxY(self.aContextLabel.frame)+20*kUIScaleBasePlus;
}

#pragma mark - 获取数据
- (void)getHelpCenterDate:(NSDictionary *)dic
{
    self.qContextLabel.text = dic[@"qContext"];
    [self.qContextLabel sizeToFit];
    
    self.aContextLabel.text = dic[@"aContext"];
    [self.aContextLabel setY:CGRectGetMaxY(self.qContextLabel.frame)+17*kUIScaleBasePlus];
    [self.aContextLabel sizeToFit];

    [self.iconAImageView setY:CGRectGetMaxY(self.qContextLabel.frame)+16*kUIScaleBasePlus];
}

@end
